﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using BaseData;
using BaseLib.Helper;
using BaseUtility;
using Newtonsoft.Json;
namespace WebUI.Ashx.App
{
    /// <summary>
    /// LoginCheck 的摘要说明
    /// </summary>
    public class LoginCheck : Base, IHttpHandler
    {
        private readonly AccClass _accId = new AccExts(new GetAccType().Parse(Request.QueryString["url"])).Instances;
        public void ProcessRequest(HttpContext context)
        {
            MsgErr msg;
            try
            {
                msg = _accId.Id > 0
                    ? new MsgErr { id = _accId.Id, error = 0, type = "info", title = _accId.Name, message = new StringBuilder("【AccName:" + _accId.Name + "】\n已成功登录！"), }
                    : new MsgErr { id = 0, error = 1, type = "error", message = new StringBuilder("未登录，请登录再试！"), };
            }
            catch (Exception err)
            {
                msg = new MsgErr { id = 0, error = 1, type = "error", message = new StringBuilder(err.Message), };
            }
            msg.account = _accId.Type.ToString();
            msg.action = "检测";
            context.Response.Write(msg.ObjectsToJson());
            context.Response.ContentType = "text/plain";
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}